package com.bjc.principle.segregation;

/**
 * @program: DesignPattern
 * @description:   接口隔离原则
 * @author: bjc
 * @create: 2020-12-13 15:34
 */
public class Segregation1 {
    public static void main(String[] args) {

    }
}

interface InterFace1{
    void operation1();
    void operation2();
    void operation3();
    void operation4();
    void operation5();
}

class B implements InterFace1{

    public void operation1() {
        System.out.println("B实现了operation1");
    }

    public void operation2() {
        System.out.println("B实现了operation2");
    }

    public void operation3() {
        System.out.println("B实现了operation3");
    }

    public void operation4() {
        System.out.println("B实现了operation4");
    }

    public void operation5() {
        System.out.println("B实现了operation5");
    }
}

class D implements InterFace1{

    public void operation1() {
        System.out.println("D实现了operation1");
    }

    public void operation2() {
        System.out.println("D实现了operation2");
    }

    public void operation3() {
        System.out.println("D实现了operation3");
    }

    public void operation4() {
        System.out.println("D实现了operation4");
    }

    public void operation5() {
        System.out.println("D实现了operation5");
    }
}

class A{ //A类通过接口Interface1依赖（使用）B类，但是只会使用到1，2，3方法
    public void depend1(InterFace1 i){
        i.operation1();
    }
    public void depend2(InterFace1 i){
        i.operation1();
    }
    public void depend3(InterFace1 i){
        i.operation1();
    }
}

class C{ //C类通过接口Interface1依赖（使用）D类，但是只会使用到1，4，3方法
    public void depend1(InterFace1 i){
        i.operation1();
    }
    public void depend4(InterFace1 i){
        i.operation1();
    }
    public void depend5(InterFace1 i){
        i.operation1();
    }
}
